/**
 * 贷后管理贷后跟踪控制器
 */
import $_fn from '~plugins'
import './index.less'
export default ['$scope','$rootScope','$location','$ui','http','$state',function($scope,$rootScope,$location,$ui,http,$state) {
    $scope.$_fn = $_fn
    //初始化对象
    $scope.err={}
    $scope.params={}
    $scope.params.pageNum = 1
    $scope.params.loan_type = -1
    $scope.params.at_id = -1
    $scope.params.type = -1
    $scope.params.status = -1
	//四级按钮
	$scope.tabMenu = $_fn.getCurrMenu($location.path())
    console.log($scope.tabMenu)
    $scope.subMenu = $scope.tabMenu.children[0].children
    console.log($scope.subMenu)
    var search = $location.search()
	$scope.params = $location.search()
    //提示错误
    $scope.errorToast = function(text) {
        $ui.toast({text:text,type:'warning',position:'center',appendTo:'.main-content'});
    }
	//四级按钮页面跳转方法
	$scope.operation = function (path,item) {
		console.log('111')
        var _path = path.split('@')
        let params = JSON.stringify(item)
        console.log(item)
        console.log(path)
        if(_path[0] == 'link'){
            console.log(path)
            $state.go(_path[1], item)
        }
        if(_path[0] == 'alert'){
            $ui.modal({content:"<"+_path[1]+" params="+params+"></"+_path[1]+">"})
        }
   }
   //分页参数
    $scope.page = {
      current: search.pageNum ||  1
    }
	

	$scope.param1={
		status:0
	}
	//获取数据的函数
    $scope.getDada = function(page, params){
        params.pageNum = page
        http.post('selectAfterLoanTrackingInit.do',params,function (data) {
            var _data = data.data
            $scope.page.pageNum =  $scope.page.current
            $scope.page.pageSize = _data.pageSize
            $scope.page.total = _data.total
            if(data.errcode > 0){
                $scope.$apply(function () {
                    $scope.param1.dataList = data.data.orderList.list;
                    $scope.param1.orderList = data.data.orderList;
                    $scope.param1.stateList = data.data.stateList;//状态
                    $scope.param1.applyTermList = data.data.applyTermList;//期限
                })
            }else{
            	$scope.errorToast(data.errmsg)
            }
        })
    }
	$scope.getDada('1',$scope.params)
    //搜索
    $scope.searchHandle = function () {
      if($scope.params.keyword && $scope.params.type==-1){
        $scope.err.type = true
        $scope.errorToast('左侧字段没有选择')
        return
      }
      $location.search($scope.params)
      $scope.getDada(1,$scope.params)
    }

    $scope.select = [{name:'以租代购',value:1},{name:'信贷方式',value:2}]

    $scope.todayGather = function () {
        http.post('selectTodayPayment.do',{},function (data) {
            var _data = data.data
            if(data.errcode > 0){
                $scope.$apply(function () {
                    $scope.param1.dataList = data.data.list;
                })
            }else{
                $scope.errorToast(data.errmsg)
            }
        })

    }
}]
